function wf = trainEpochSimplePerceptron(X, wi, b)
    global ETA;
%TRAINSIMPLEPERCEPTRON
%   This function trains a simple perceptron with a given set
%   of patterns (X), an initial weiths (wi), the expected 
%   solution for each pattern (b). An exitation function (g)
%   and its derived function (dg) and returns the trained weiths
%   of the neuron (wf)
%   
%   Input
%
%   X:  The set of patterns.
%   wi: The initial weight for each input, vector. 
%   b:  The expected solution for each pattern.
%   g:  activation function.
%   dg: derivated activation function.
%
%   Output:
%   wf: The vector of of the trained weights.

    len = length(X(:,1));
    for i = 1:len
       xi = horzcat(-1, X(i, :));   % We add the -1 as the threshold
       hi = xi*wi;
       oi = g_function(hi);
       gpvalue = gp_function(hi);
       deltai = (b(i) - oi)*gpvalue;
       wi = wi + ETA*deltai*xi';
    end
    wf = wi;
end